package com.dongdongshop.common;


import com.dongdongshop.em.ResultEnum;

public class Result<T> {
    private Integer code;  //返回状态码
    private String message;   //返回提示信息
    private T data;   //返回数据

    public static Result OK(){
        return new Result(10000,"操作成功");
    }
    public static Result ERROR(){
        return new Result(99999,"操作失败");
    }
    public static Result Response(ResultEnum em){
        return new Result(em.getNum(),em.getName());
    }


    public Result() {
    }

    public Result(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public Result(Integer code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public com.dongdongshop.common.Result<T> setData(T data) {
        this.data = data;
        return this;
    }
}
